<template>
    <div class="help-page">
        <van-nav-bar title="Help & Support" left-text="Back" left-arrow @click-left="$router.back()" />

        <div class="help-content">
            <!-- FAQ Section -->
            <div class="help-section">
                <h2>Frequently Asked Questions</h2>
                <van-collapse v-model="activeNames">
                    <van-collapse-item v-for="faq in faqs" :key="faq.id" :title="faq.question" :name="faq.id">
                        <div class="faq-answer">{{ faq.answer }}</div>
                    </van-collapse-item>
                </van-collapse>
            </div>

            <!-- Contact Section -->
            <div class="help-section">
                <h2>Contact Support</h2>
                <div class="contact-options">
                    <div class="contact-item" @click="sendEmail">
                        <van-icon name="envelop-o" />
                        <div class="contact-info">
                            <div class="contact-title">Email Support</div>
                            <div class="contact-desc">Get help via email</div>
                        </div>
                    </div>
                    <div class="contact-item" @click="openChat">
                        <van-icon name="chat-o" />
                        <div class="contact-info">
                            <div class="contact-title">Live Chat</div>
                            <div class="contact-desc">Chat with our team</div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Guides Section -->
            <div class="help-section">
                <h2>User Guides</h2>
                <div class="guides-list">
                    <div class="guide-item" @click="openGuide('getting-started')">
                        <van-icon name="play-circle-o" />
                        <div class="guide-info">
                            <div class="guide-title">Getting Started</div>
                            <div class="guide-desc">Learn the basics of Social Dojo</div>
                        </div>
                        <van-icon name="arrow" />
                    </div>
                    <div class="guide-item" @click="openGuide('training')">
                        <van-icon name="medal-o" />
                        <div class="guide-info">
                            <div class="guide-title">Training Sessions</div>
                            <div class="guide-desc">How to make the most of your practice</div>
                        </div>
                        <van-icon name="arrow" />
                    </div>
                    <div class="guide-item" @click="openGuide('community')">
                        <van-icon name="friends-o" />
                        <div class="guide-info">
                            <div class="guide-title">Community Features</div>
                            <div class="guide-desc">Connect and share with others</div>
                        </div>
                        <van-icon name="arrow" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { showToast } from 'vant'

const activeNames = ref<string[]>([])

const faqs = ref([
    {
        id: '1',
        question: 'How do I start my first training session?',
        answer: 'Go to the Training tab, select a character, choose a scenario, and start practicing! The AI will guide you through realistic conversations.'
    },
    {
        id: '2',
        question: 'What are achievements and how do I earn them?',
        answer: 'Achievements are badges you earn by completing training sessions, reaching milestones, and participating in the community. Check your profile to see your progress.'
    },
    {
        id: '3',
        question: 'How does the progress tracking work?',
        answer: 'Your progress is tracked across different social skills like communication, confidence, and empathy. Complete training sessions to improve your scores.'
    },
    {
        id: '4',
        question: 'Can I practice with different difficulty levels?',
        answer: 'Yes! Each scenario has different difficulty levels. Start with beginner and work your way up as you become more confident.'
    },
    {
        id: '5',
        question: 'How do I reset my password?',
        answer: 'Go to the login page and click "Forgot Password". Enter your email address and follow the instructions sent to your inbox.'
    }
])

const sendEmail = () => {
    window.location.href = 'mailto:support@socialdojo.com?subject=Help Request'
}

const openChat = () => {
    showToast('Live chat will be available soon!')
}

const openGuide = (guideType: string) => {
    showToast(`Opening ${guideType} guide...`)
    // In a real app, this would navigate to detailed guide pages
}
</script>

<style lang="scss" scoped>
.help-page {
    min-height: 100vh;
    background: #f8f9fa;
}

.help-content {
    padding: 16px;
}

.help-section {
    margin-bottom: 24px;

    h2 {
        font-size: 18px;
        font-weight: 600;
        color: #323233;
        margin-bottom: 16px;
    }
}

.faq-answer {
    color: #646566;
    line-height: 1.5;
    padding: 8px 0;
}

.contact-options {
    display: flex;
    flex-direction: column;
    gap: 12px;

    .contact-item {
        display: flex;
        align-items: center;
        gap: 12px;
        background: white;
        border-radius: 12px;
        padding: 16px;
        cursor: pointer;
        transition: all 0.3s ease;

        &:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        .van-icon {
            font-size: 24px;
            color: #1989fa;
        }

        .contact-info {
            flex: 1;

            .contact-title {
                font-size: 16px;
                font-weight: 500;
                color: #323233;
                margin-bottom: 4px;
            }

            .contact-desc {
                font-size: 14px;
                color: #969799;
            }
        }
    }
}

.guides-list {
    display: flex;
    flex-direction: column;
    gap: 12px;

    .guide-item {
        display: flex;
        align-items: center;
        gap: 12px;
        background: white;
        border-radius: 12px;
        padding: 16px;
        cursor: pointer;
        transition: all 0.3s ease;

        &:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        .van-icon:first-child {
            font-size: 24px;
            color: #07c160;
        }

        .guide-info {
            flex: 1;

            .guide-title {
                font-size: 16px;
                font-weight: 500;
                color: #323233;
                margin-bottom: 4px;
            }

            .guide-desc {
                font-size: 14px;
                color: #969799;
            }
        }

        .van-icon:last-child {
            font-size: 16px;
            color: #c8c9cc;
        }
    }
}

:deep(.van-collapse-item__title) {
    font-weight: 500;
}
</style>